// DBStretchImage.h: interface for the DBStretchImage class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DBSTRETCHIMAGE_H__0E093D54_A71E_4A41_A7C1_8043746506D4__INCLUDED_)
#define AFX_DBSTRETCHIMAGE_H__0E093D54_A71E_4A41_A7C1_8043746506D4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MemDC.h"

class DBStretchImage  
{
public:
	struct STRENTCH{
		public:
			static HBITMAP ScaleBitmap( HDC hDC, HBITMAP hBmp, WORD wNewWidth, WORD wNewHeight, BOOL fastScale );
			
		private:
			// helper function prototypes 
			static BITMAPINFO *PrepareRGBBitmapInfo(WORD wWidth, 
				WORD wHeight); 
			static int * CreateCoeffInt(int nLen, int nNewLen, BOOL bShrink);
			static float * CreateCoeff(int nLen, int nNewLen, BOOL bShrink);
			static void ShrinkDataInt( BYTE *pInBuff, WORD wWidth, WORD wHeight, 
				BYTE *pOutBuff, WORD wNewWidth, WORD wNewHeight); 
			static void EnlargeDataInt( BYTE *pInBuff, WORD wWidth, WORD wHeight, 
				BYTE *pOutBuff, WORD wNewWidth, WORD wNewHeight); 
			static void ShrinkData( BYTE *pInBuff, WORD wWidth, WORD wHeight, 
				BYTE *pOutBuff, WORD wNewWidth, WORD wNewHeight); 
			static void EnlargeData( BYTE *pInBuff, WORD wWidth, WORD wHeight, 
				BYTE *pOutBuff, WORD wNewWidth, WORD wNewHeight); 
	};

public:
	HBITMAP		m_hBmpDib;

	BOOL LoadDibSection(LPCSTR lpszBmpPath);
	BOOL IsEmpty();
	void SetBitmap(CBitmap *pBitmap);
	int Height() const;
	int Width() const;
	void Render(CDC *pDC,CPoint pt,CSize size);
	
	void LoadBitmap(UINT nIDResource, 
		int iDividePosFir, int iDividePosSec, BOOL bHStretch = TRUE);

	void LoadBitmap(LPCSTR lpszBitmap, 
		int iDividePosFir, int iDividePosSec, BOOL bHStretch = TRUE);

	void LoadBitmap(HBITMAP hBmp, 
		int iDividePosFir, int iDividePosSec, BOOL bHStretch = TRUE);

	DBStretchImage();
	virtual ~DBStretchImage();

private:
	BOOL m_bHStretch;
	CSize m_szSrcBmp;
	CBitmap m_bmpMiddle;
	CBitmap m_bmpStart;
	CBitmap m_bmpEnd;
	int m_iDividePosFir;
	int m_iDividePosSec;
	CString m_strBmpName;
};

#endif // !defined(AFX_DBSTRETCHIMAGE_H__0E093D54_A71E_4A41_A7C1_8043746506D4__INCLUDED_)
